home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 410 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: solon.com!not-for-mail
  2. From: Chris Torek <torek@elf.bsdi.com>
  3. Newsgroups: comp.std.c,comp.lang.c.moderated
  4. Subject: Re: Integral promotion.
  5. Date: 16 Feb 1996 09:23:03 -0600
  6. Organization: Berkeley Software Design, Inc.
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4g27gn$q5k@solutions.solon.com>
  10. References: <4fstj7$2l6@solutions.solon.com> <4fu835$9de@solutions.solon.com> <4fvgrm$dv9@solutions.solon.com>
  11. Reply-To: torek@bsdi.com
  12. NNTP-Posting-Host: solutions.solon.com
  13.  
  14. In article <4fvgrm$dv9@solutions.solon.com>,  <msb@sq.com> wrote:
  15. >Oh dear, I have to correct Chris Torek (torek@bsdi.com).
  16.  
  17. Heh... it happens, especially when I am in a hurry (as I was this time).
  18. You can usually tell a hurried article by its length: I need time to
  19. write a short one.
  20.  
  21. >... If int and short are the same width, overflow can occur, with
  22. >undefined behavior.  [But if int is wider than short, the sum is
  23.  done in the wider precision and does not overflow, and then:]
  24.  
  25. >Excerpts from the standard:
  26. >
  27. >*  From 6.3.16.1/3.3.16.1:
  28. >#  In "simple assignment" (=), the value of the right operand is
  29. >#  converted to the type of the left operand ...
  30. >
  31. >*  From 6.2.1.2/3.2.1.2:
  32. >#  When a value with integral type is demoted to a signed integer with
  33. >#  smaller size ... if the value cannot be represented the result is
  34. >#  implementation-defined.
  35. >
  36. >Hence implementation-defined behavior occurs.
  37.  
  38. Thus, the implementation has to say exactly how it handles this.
  39. There is still some question as to whether the implementation can
  40. define it as an overflow resulting in program termination, is there
  41. not?
  42. -- 
  43. In-Real-Life: Chris Torek, Berkeley Software Design Inc
  44. El Cerrito, CA    Domain:    torek@bsdi.com    +1 510 234 3167
  45.